const os = require('os')

exports.getLocalIp = function () {
  let networks = Object.values(os.networkInterfaces());
  let address = 'localhost'
  let arr = []
  networks.forEach( (item) => {
    arr = arr.concat(item.filter((item) => {
      return item.family === 'IPv4'
    }))
  })
  arr.forEach( (item) => {
    if (item.address !== '127.0.0.1' && item.address !== 'localhost') {
      address = item.address
    }
  })
  return address
}
